<template>
    <view>
        <web-view src="http://10.254.61.254:5173:"></web-view>
    </view>
</template>

<script lang="ts" setup>

const blueDeviceList = []

function initBlue() {
    uni.openBluetoothAdapter({
        success(res) {
            console.log('初始化蓝牙成功', res);
        },
        fail(err) {
            console.log('初始化蓝牙失败', err);
        },
    });
}

// 2. 搜索附近的蓝牙设备
function discovery() {
    uni.startBluetoothDevicesDiscovery({
        success(res) {
            console.log('开始搜索蓝牙设备', res);
            // 开启监听回调
            uni.onBluetoothDeviceFound(function (devices) {
                console.log('扫到的蓝牙设备', devices);
                if (devices) {
                    const device = devices.devices[0];
                    if (device.name) {
                        blueDeviceList.push(device);
                    }
                }
            });
        },
        fail(err) {
            console.log('搜索蓝牙设备失败', err);
        },
    });
}


</script>

<style></style>
